package com.androidviewx;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.viewfloat.FloatingMagnetView;
import com.viewfloat.FloatingView;
import com.viewfloat.MagnetViewListener;

/**
 * 必须依靠activity 实现
 *   override fun onStart() {
 *         super.onStart()
 *         FloatingView.get().attach(this)
 *     }
 *  override fun onStop() {
 *         super.onStop()
 *         FloatingView.get().detach(this)
 *     }
 */
public class DemoViewFloatActivity extends AppCompatActivity {
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo_view_float);
        FloatingView.get().listener(new MagnetViewListener() {
            @Override
            public void onRemove(FloatingMagnetView magnetView) {
                Log.d("xxxxx","移除当前的悬浮窗");
            }

            @Override
            public void onClick(FloatingMagnetView magnetView) {
                Log.d("xxxxx","点击当前的悬浮窗");
            }
        });
    }

    public void addFloat(View view) {
        FloatingView.get().add();
    }
    public void removeFloat(View view) {
        FloatingView.get().remove();
    }
}
